<?php


namespace app\api\controller\v1;


use app\api\model\DataExportTaskModel;
use app\common\controller\UserBaseController;

class TaskController extends UserBaseController
{
    function progressAction()
    {
        $this->paramlist = array(
            'tag' => 'string',
            'progress' => 'int',
            'output' => 'optarray',
        );

        $this->check_params();
        //$this->check_token();


        (new DataExportTaskModel())->update_progress($this->argv['tag'], $this->argv['progress'], $this->argv['output']);
        //hilog::debug($this->argv, "#####################");

        return $this->ret_resp();
    }

    function listAction()
    {
        $this->paramlist = array(
            'type' => 'string',
            'pno' => 'int',
            'psize' => 'int',
        );

        $this->check_params();
        $this->check_token();


        $l = (new DataExportTaskModel())->query_list($this->city_id, $this->argv['type'], $this->argv['pos'], $this->argv['limit']);
        $this->resp['list'] = $l;
        if (empty($l)) {
            $this->resp['total'] = 0;
        } else {
            $this->resp['total'] = hisql::query_count();
        }

        return $this->ret_resp();
    }

}
